package vip.liux.front.infrastructure.code;

import org.springframework.plugin.core.PluginRegistry;
import org.springframework.stereotype.Component;
import vip.liux.cache.code.CodeCategory;
import vip.liux.cache.code.CodeGenerator;

@Component
public class BizCodeGenerator {

    private final CodeGenerator codeGenerator;

    public BizCodeGenerator(PluginRegistry<CodeGenerator, CodeCategory> pluginRegistry) {
        this.codeGenerator = pluginRegistry.getRequiredPluginFor(CodeCategory.REDIS);
    }

    public String generateCouponNo() {
        return "C-" + codeGenerator.generateSerialNumber("COUPON");
    }

    public String generatePaymentRequestCode(String paymentRequest) {
        return "PRO-" + codeGenerator.generateSerialNumber(paymentRequest);
    }

    public String generateUserCouponCode() {
        return "UC-" + codeGenerator.generateSerialNumber("USER_COUPON");
    }
}
